﻿@model Dashboard.Models.HealthView

@{
    ViewBag.Title = "Server performance";
}

<h3>Server performance <small>displays history of RAM, CPU & hard disk activity</small></h3>
<hr />

<div class="row">
    <div class="col-md-12">
        <div id="performanceHistory"></div>
    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/highcharts")

    <script type="text/javascript">
        var performanceHistoryChart;

        $(document).ready(function () {
            Highcharts.setOptions({
                global: {
                    useUTC: true
                }
            });
        });

        $(function () {

            performanceHistoryChart = new Highcharts.Chart({
                chart: {
                    //height: 300,
                    type: 'spline',
                    renderTo: 'performanceHistory',
                    animation: Highcharts.svg, // don't animate in old IE
                    marginRight: 10
                },

                title: {
                    text: null
                },

                credits: {
                    enabled: false
                },

                xAxis: {
                    type: 'datetime'
                },

                yAxis: {
                    min: 0,
                    title: {
                        text: null
                    }
                },

                legend: {
                    enabled: true
                },

                exporting: {
                    enabled: false
                },

                series: [{
                    name: 'CPU averaged',
                    data: @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.CpuUsageAveraged))
                    }, {
                    name: 'CPU usage',
                    data: @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.CpuUsage))
                    }, {
                    name: 'Disk averaged',
                    data: @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.DiskUsageAveraged))
                    }, {
                    name: 'Disk usage',
                    data: @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.DiskUsage))
                    }, {
                    name: 'Ram total',
                    data: @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.RamTotal))
                    }, {
                    name: 'Ram usage',
                    data: @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.RamUsage))
                    }]
            });
        });

    </script>
}